package com.xored.glance.ui.viewers.descriptors;

import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Tree;

import com.xored.glance.internal.ui.viewers.TreeViewerSource;
import com.xored.glance.ui.sources.ITextSource;
import com.xored.glance.ui.sources.ITextSourceDescriptor;
import com.xored.glance.ui.viewers.utils.ViewerUtils;

public class TreeViewerDescriptor implements ITextSourceDescriptor {

	@Override
	public boolean isValid(Control control) {
		if (control instanceof Tree) {
			return ViewerUtils.getTreeViewer((Tree) control) != null;
		}
		return false;
	}

	@Override
	public ITextSource createSource(Control control) {
		return new TreeViewerSource((Tree) control);
	}
}
